Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add touch support #67

Closed
wants to merge 14 commits into from
Closed

Feature/add touch support #67

wants to merge 14 commits into from

Conversation

joancc
Copy link

@joancc joancc commented Nov 21, 2020

Description

Add touch support for:

  1. Dragging nodes
  2. Dragging segments from nodes
  3. Creating segments on touchend at new port

Related Issue

Closes #60

Motivation and Context

Closes #60

How Has This Been Tested?

All existing tests are passing.
Tested on the Chrome mobile simulator on a mac and Safari on an iPad.

@joancc
Copy link
Author

joancc commented Nov 21, 2020

@antonioru you mentioned in the original issue the use of useMouse from your hooks library, but I was unable to find a reference to it. Let me know if I missed something.

@joancc
Copy link
Author

joancc commented Nov 21, 2020

Marked as WIP for now since it's breaking related to issue #68

@antonioru
Copy link
Owner

antonioru commented Nov 23, 2020

Hello @joancc
thank you for the huge merge request, I really appreciate your effort!
Yes, I think I've mentioned the useMouse hook from the library beautiful-react-hooks in another issue, but recently I'm working on pan/zoom functionality for the canvas and I've found a fancy way to use both touch and mouse events at the same time, please take a look at this:
#70

Perhaps we can use the same approach in your MR?

@joancc
Copy link
Author

joancc commented Nov 25, 2020

Thanks @antonioru! I think I managed totrack the relevant stuff to useCanvasPanHandlers.js:

const getMouseEventPoint = (e) => ({ x: e.pageX, y: e.pageY });
const getTouchEventPoint = (e) => getMouseEventPoint(e.changedTouches[0]);
const getEventPoint = isTouch ? getTouchEventPoint : getMouseEventPoint;

I'll recreate the CONSTANTS file in my PR and perhaps ass this mouse/touch logic in a separate hook?

I'll look closer at the use of these in your PR, butI think that's the important stuff, right?

@antonioru
Copy link
Owner

Yes, you're absolutely right: it is very important to support the touch event as indeed I was already working on it:

https://github.com/beautifulinteractions/beautiful-react-diagrams/blob/feature/canvas-ext/src/components/NodeDraggableElement/useDragAround.js

:)

Btw, would you mind to target your PR to the feature/canvas branch?
That is the branch of the next version 0.6.0 which will definitely solve a lot of issues and improve performances

@joancc
Copy link
Author

joancc commented Nov 27, 2020

Closing in favor of #82

@joancc joancc closed this Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Touch Events
3 participants